<template>
  <div  class="mod-config">
    <div>培训计划</div>
    <el-form :inline="true" :model="dataForm">
      <el-form-item label="培训班名称">
        <el-input v-model="dataForm.name"></el-input>
      </el-form-item>
      <el-form-item label="培训班名称">
        <el-input v-model="dataForm.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary">查询</el-button>
        <el-button type="primary" @click="addOrUpdate">新增</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      style="width:100%"
    >
      <el-table-column label="序号" type="index" align="center"></el-table-column>
      <el-table-column label="培训计划名称" prop="planeName" align="center"></el-table-column>
      <el-table-column label="培训单位" prop="trainUnit" align="center"></el-table-column>
      <el-table-column label="发布状态" align="center">
        <template slot-scope="scope">
          <el-button
            type="primary"
            v-if="parseInt(scope.row.status) === 0"
          >发布
          </el-button>
          <el-tag v-else>已发布</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="培训类别" prop="trainCate" align="center"></el-table-column>
      <el-table-column label="培训类型" prop="trainType" align="center"></el-table-column>
      <el-table-column label="开始时间" prop="startTime" align="center"></el-table-column>
      <el-table-column label="结束时间" prop="endTime" align="center"></el-table-column>
      <el-table-column label="资质级别" prop="levelQua"  align="center"></el-table-column>
      <el-table-column label="培训范围" prop="regArea" align="center"></el-table-column>
      <el-table-column label="培训地点" prop="trainPlace" align="center"></el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="text">修改</el-button>
          <el-button type="text">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
     @size-change="sizeChange"
     @current-change="currentChange"
     :current-page="dataForm.pageIndex"
     :page-sizes="[10, 20, 50]"
     :page-size="dataForm.pageSize"
     :total="dataForm.totalPage"
     layout="total, sizes, prev, pager, next, jumper"
    ></el-pagination>

    <plane-add-or-update ref="planeAddOrUpdate" @refreshDataList="getDataList"></plane-add-or-update>
  </div>
</template>

<script>
  import PlaneAddOrUpdate from './plane-add-or-update'
  export default {
    name: 'active-plane',
    data() {
      return {
        dataList: [],
        dataForm: {
          pageIndex: 1,
          pageSize: 10,
          totalPage: 0
        }
      }
    },
    components: {
      PlaneAddOrUpdate
    },
    mounted() {
      this.getDataList()
    },
    methods: {
      async getDataList() {
        this.dataListLoading = true
        var res = await this.$http.post('/active/plane/page', {
          page: this.dataForm.pageIndex,
          limit: this.dataForm.pageSize
        })
        this.dataList = res.data.list
        this.totalPage = res.data.totalCount
      },
      sizeChange(val) {

      },
      currentChange(val) {

      },
      addOrUpdate() {
        this.$nextTick(() => {
          this.$refs.planeAddOrUpdate.init()
        })
      }
    }
  }
</script>

<style scoped>

</style>
